package com.backedserver.controller.casemanage;

import com.common.base.BindCreateBy;
import com.common.requestvo.casemanage.CaseProblemSituationReqVo;
import com.common.service.casemanage.CaseService;
import com.common.utils.ResultVoUtil;
import com.common.vo.ResultVo;
import com.common.vo.casemanage.CaseProblemSituationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author johnny
 * @create 2021-05-23 10:30 下午
 **/
@Api(tags = "问题情形 模块")
@RestController
@RequestMapping("/case_problem_situation")
@Slf4j
public class CaseProblemSituationController {

    private final CaseService caseService;

    public CaseProblemSituationController(CaseService caseService) {
        this.caseService = caseService;
    }
    //问题情形

    @GetMapping("/findAllCaseProblem")
    @ApiOperation(value = "查询所有的 问题 ")
    public ResultVo findAllCaseProblem() {
        List<CaseProblemSituationVo> caseProblemSituationVoList = caseService.findAllCaseProblem();
        return ResultVoUtil.success(caseProblemSituationVoList);
    }

    @GetMapping("/findCaseSituationByProblemId/{id}")
    @ApiOperation(value = "查询情形 根据问题Id ")
    public ResultVo findCaseSituationByProblemId(@PathVariable("id") Long problemId) {
        List<CaseProblemSituationVo> caseProblemSituationVoList = caseService.findCaseSituationByProblemId(problemId);
        return ResultVoUtil.success(caseProblemSituationVoList);
    }


    @PostMapping("/addCaseProblemSituation")
    @ApiOperation(value = "添加 问题情形")
    @BindCreateBy
    public ResultVo addCaseProblemSituation(@RequestBody CaseProblemSituationReqVo caseProblemSituationReqVo) {
        caseService.addCaseProblemSituation(caseProblemSituationReqVo);
        return ResultVoUtil.success();
    }

    @PostMapping("/editCaseProblemSituation")
    @ApiOperation(value = "修改 问题情形")
    @BindCreateBy
    public ResultVo editCaseProblemSituation(@RequestBody CaseProblemSituationReqVo caseProblemSituationReqVo) {
        caseService.editCaseProblemSituation(caseProblemSituationReqVo);
        return ResultVoUtil.success();
    }


    @GetMapping("/deleteProblem/{id}")
    @ApiOperation(value = "删除 问题（连带删除下面的所有情形）")
    public ResultVo deleteProblem(@PathVariable Long id) {
        caseService.deleteProblem(id);
        return ResultVoUtil.success();
    }


    @GetMapping("/deleteSituation/{id}")
    @ApiOperation(value = "删除 情形")
    public ResultVo deleteSituation(@PathVariable Long id) {
        caseService.deleteSituation(id);
        return ResultVoUtil.success();
    }
}